package com.demo.demoTest;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author lkz
 * @ClassName: Test
 * @description: TODO
 * @date 2022/6/8 16:26
 */
public class Test {

    public static void main(String[] args) {
        // 是否陪检 等级 名字 床号 运送类型 描述
      Order order1=  new Order(1,0,"订单1","1","运送类型","描述1" );
      Order order2=  new Order(0,1,"订单2","1","运送类型","描述2");
      Order order3=  new Order(1,2,"订单1","1","运送类型","描述3");
      Order order4=  new Order(0,1,"订单4","1","运送类型","描述4");
      Order order5=  new Order(1,2,"订单5","1","运送类型","描述5");
      Order order6=  new Order(0,1,"订单6","1","运送类型","描述6");
      Order order7=  new Order(1,0,"订单7","7","运送类型","描述7");
      Order order8=  new Order(1,1,"订单1","1","运送类型","描述8");
      Order order9=  new Order(0,1,"订单9","1","运送类型","描述9");
      Order order10=  new Order(1,1,"订单7","7","运送类型","描述10");


        List<Order> list=new ArrayList<>();
        list.add(order1);list.add(order2);  list.add(order3);list.add(order4);list.add(order5);
        list.add(order6);list.add(order7);  list.add(order8);list.add(order9);list.add(order10);
      Comparator<Order> comparator = Comparator
              .comparing(Order::getPriority, (x,y) -> y-x);
      list = list.stream().sorted(comparator).collect(Collectors.toList());

      System.out.println(list);
        Map<String, List<Order>> collect = list.stream().collect(Collectors.groupingBy(Order::getName));
      int size = collect.size();
      Pager<Map<String, List<Order>>> pager = new Pager<>();
      pager.setCurentPageIndex(1);
      pager.setCountPerpage(5);
     // pager.setBigList(collect);
      pager.getRecordCount();//得到总条数
      pager.getSmallList();//得到小的集合(分页的当前页的记录)

    }
}
